#include "HtmlBuilder.h"
#include <QFile>
#include <QApplication>

HtmlBuilder* HtmlBuilder::instance = nullptr;

HtmlBuilder::HtmlBuilder()
{
    auto htmlFile = QFile(QApplication::applicationDirPath() + "/html/live2d.html");
    htmlFile.open(QFile::ReadOnly);
    htmlTemplate = htmlFile.readAll();
    htmlFile.close();

    auto configList = Config::Instance()->GetModelList();
    /*
    for(const auto& i : configList)
    {
        auto jsFile = QFile(QApplication::applicationDirPath() + "/html/modelScript/" + i + ".js");
        jsFile.open(QFile::ReadOnly);
        auto wConfigFile = QFile(QApplication::applicationDirPath() + "/html/config/" + i + ".json");
        wConfigFile.open(QFile::ReadOnly);
        auto dom = QJsonDocument::fromJson(wConfigFile.readAll());
        configMap.insert(i, {
            jsFile.readAll(),
            QSize(dom["window"]["width"].toInt(), dom["window"]["height"].toInt())});
        jsFile.close();
        wConfigFile.close();
    }
    */
}
